<?php

namespace IDock\Insurance\AMIC\Response;

use IDock\Http\Response;
use IDock\Insurance\AMIC\Response\AllAMICResponse;
use IDock\Printer\PremiumUnderwritingPrinter;

class UnderwritingResponse extends AllAMICResponse
{

    /**
     * @var PremiumUnderwritingPrinter $printer
     */
    public $printer = PremiumUnderwritingPrinter::class;

    public function printerInit(): Response
    {
        $data = $this->getBody()['Body']['appBase'] ?? [];
        $code = $data['autoUndrFlag'] ?? '';

        $this->printer->inquiryNo = '';
        $this->printer->ciInquiryNo = $data['applyNoCI'] ?? '';
        $this->printer->biInquiryNo = $data['applyNoBusi'] ?? '';
        $this->printer->messageTip = $data['undrDesc'] ?? '';

        //下发
        if ($code == 2) {
            $this->printer->statusCode = 'U4';
        }
        //成功
        if ($code == 1)  {
            $this->printer->statusCode = 'U1';
        }
        //人工
        if ($code == 0) {
            $this->printer->statusCode = 'U3';
        }

        return $this;
    }
}
